.class public LPlugclass/ImageMemoryCache;
.super Ljava/lang/Object;
.source "ImageMemoryCache.java"


# static fields
.field private static final SOFT_CACHE_SIZE:I = 0xf

.field private static mLruCache:Landroid/support/v4/util/LruCache;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Landroid/support/v4/util/LruCache",
            "<",
            "Ljava/lang/String;",
            "Landroid/graphics/Bitmap;",
            ">;"
        }
    .end annotation
.end field

.field private static mSoftCache:Ljava/util/LinkedHashMap;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/LinkedHashMap",
            "<",
            "Ljava/lang/String;",
            "Ljava/lang/ref/SoftReference",
            "<",
            "Landroid/graphics/Bitmap;",
            ">;>;"
        }
    .end annotation
.end field


# direct methods
.method public constructor <init>(Landroid/content/Context;)V
    .locals 6
    .param p1, "context"    # Landroid/content/Context;

    .prologue
    .line 21
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 22
    const-string v2, "activity"

    invoke-virtual {p1, v2}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Landroid/app/ActivityManager;

    invoke-virtual {v2}, Landroid/app/ActivityManager;->getMemoryClass()I

    move-result v1

    .line 23
    .local v1, "memClass":I
    const/high16 v2, 0x100000

    mul-int/2addr v2, v1

    div-int/lit8 v0, v2, 0x4

    .line 24
    .local v0, "cacheSize":I
    new-instance v2, LPlugclass/ImageMemoryCache$1;

    invoke-direct {v2, p0, v0}, LPlugclass/ImageMemoryCache$1;-><init>(LPlugclass/ImageMemoryCache;I)V

    sput-object v2, LPlugclass/ImageMemoryCache;->mLruCache:Landroid/support/v4/util/LruCache;

    .line 40
    new-instance v2, LPlugclass/ImageMemoryCache$2;

    const/16 v3, 0xf

    const/high16 v4, 0x3f400000    # 0.75f

    const/4 v5, 0x1

    invoke-direct {v2, p0, v3, v4, v5}, LPlugclass/ImageMemoryCache$2;-><init>(LPlugclass/ImageMemoryCache;IFZ)V

    sput-object v2, LPlugclass/ImageMemoryCache;->mSoftCache:Ljava/util/LinkedHashMap;

    .line 50
    return-void
.end method

.method static synthetic access$0()Ljava/util/LinkedHashMap;
    .locals 1

    .prologue
    .line 19
    sget-object v0, LPlugclass/ImageMemoryCache;->mSoftCache:Ljava/util/LinkedHashMap;

    return-object v0
.end method


# virtual methods
.method public addBitmapToCache(Ljava/lang/String;Landroid/graphics/Bitmap;)V
    .locals 2
    .param p1, "url"    # Ljava/lang/String;
    .param p2, "bitmap"    # Landroid/graphics/Bitmap;

    .prologue
    .line 89
    if-eqz p2, :cond_0

    .line 90
    sget-object v1, LPlugclass/ImageMemoryCache;->mLruCache:Landroid/support/v4/util/LruCache;

    monitor-enter v1

    .line 91
    :try_start_0
    sget-object v0, LPlugclass/ImageMemoryCache;->mLruCache:Landroid/support/v4/util/LruCache;

    invoke-virtual {v0, p1, p2}, Landroid/support/v4/util/LruCache;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 90
    monitor-exit v1

    .line 94
    :cond_0
    return-void

    .line 90
    :catchall_0
    move-exception v0

    monitor-exit v1
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    throw v0
.end method

.method public clearCache()V
    .locals 1

    .prologue
    .line 97
    sget-object v0, LPlugclass/ImageMemoryCache;->mSoftCache:Ljava/util/LinkedHashMap;

    invoke-virtual {v0}, Ljava/util/LinkedHashMap;->clear()V

    .line 98
    return-void
.end method

.method public getBitmapFromCache(Ljava/lang/String;)Landroid/graphics/Bitmap;
    .locals 5
    .param p1, "url"    # Ljava/lang/String;

    .prologue
    .line 58
    sget-object v4, LPlugclass/ImageMemoryCache;->mLruCache:Landroid/support/v4/util/LruCache;

    monitor-enter v4

    .line 59
    :try_start_0
    sget-object v3, LPlugclass/ImageMemoryCache;->mLruCache:Landroid/support/v4/util/LruCache;

    invoke-virtual {v3, p1}, Landroid/support/v4/util/LruCache;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Landroid/graphics/Bitmap;

    .line 60
    .local v1, "bitmap":Landroid/graphics/Bitmap;
    if-eqz v1, :cond_0

    .line 62
    sget-object v3, LPlugclass/ImageMemoryCache;->mLruCache:Landroid/support/v4/util/LruCache;

    invoke-virtual {v3, p1}, Landroid/support/v4/util/LruCache;->remove(Ljava/lang/Object;)Ljava/lang/Object;

    .line 63
    sget-object v3, LPlugclass/ImageMemoryCache;->mLruCache:Landroid/support/v4/util/LruCache;

    invoke-virtual {v3, p1, v1}, Landroid/support/v4/util/LruCache;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 64
    monitor-exit v4

    move-object v3, v1

    .line 82
    :goto_0
    return-object v3

    .line 58
    :cond_0
    monitor-exit v4
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 68
    sget-object v4, LPlugclass/ImageMemoryCache;->mSoftCache:Ljava/util/LinkedHashMap;

    monitor-enter v4

    .line 69
    :try_start_1
    sget-object v3, LPlugclass/ImageMemoryCache;->mSoftCache:Ljava/util/LinkedHashMap;

    invoke-virtual {v3, p1}, Ljava/util/LinkedHashMap;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Ljava/lang/ref/SoftReference;

    .line 70
    .local v2, "bitmapReference":Ljava/lang/ref/SoftReference;, "Ljava/lang/ref/SoftReference<Landroid/graphics/Bitmap;>;"
    if-eqz v2, :cond_2

    .line 71
    invoke-virtual {v2}, Ljava/lang/ref/SoftReference;->get()Ljava/lang/Object;

    move-result-object v3

    move-object v0, v3

    check-cast v0, Landroid/graphics/Bitmap;

    move-object v1, v0

    .line 72
    if-eqz v1, :cond_1

    .line 74
    sget-object v3, LPlugclass/ImageMemoryCache;->mLruCache:Landroid/support/v4/util/LruCache;

    invoke-virtual {v3, p1, v1}, Landroid/support/v4/util/LruCache;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 75
    sget-object v3, LPlugclass/ImageMemoryCache;->mSoftCache:Ljava/util/LinkedHashMap;

    invoke-virtual {v3, p1}, Ljava/util/LinkedHashMap;->remove(Ljava/lang/Object;)Ljava/lang/Object;

    .line 76
    monitor-exit v4
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_1

    move-object v3, v1

    goto :goto_0

    .line 58
    .end local v1    # "bitmap":Landroid/graphics/Bitmap;
    .end local v2    # "bitmapReference":Ljava/lang/ref/SoftReference;, "Ljava/lang/ref/SoftReference<Landroid/graphics/Bitmap;>;"
    :catchall_0
    move-exception v3

    :try_start_2
    monitor-exit v4
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0

    throw v3

    .line 78
    .restart local v1    # "bitmap":Landroid/graphics/Bitmap;
    .restart local v2    # "bitmapReference":Ljava/lang/ref/SoftReference;, "Ljava/lang/ref/SoftReference<Landroid/graphics/Bitmap;>;"
    :cond_1
    :try_start_3
    sget-object v3, LPlugclass/ImageMemoryCache;->mSoftCache:Ljava/util/LinkedHashMap;

    invoke-virtual {v3, p1}, Ljava/util/LinkedHashMap;->remove(Ljava/lang/Object;)Ljava/lang/Object;

    .line 68
    :cond_2
    monitor-exit v4

    .line 82
    const/4 v3, 0x0

    goto :goto_0

    .line 68
    .end local v2    # "bitmapReference":Ljava/lang/ref/SoftReference;, "Ljava/lang/ref/SoftReference<Landroid/graphics/Bitmap;>;"
    :catchall_1
    move-exception v3

    monitor-exit v4
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_1

    throw v3
.end method
